import { Component, OnInit,ElementRef } from '@angular/core';
import { HttpClient } from "@angular/common/http";
import { AuthTokenService } from '@services/auth-token.service';
@Component({
  selector: 'app-pay',
  templateUrl: './pay.page.html',
  styleUrls: ['./pay.page.scss'],
})
export class PayPage implements OnInit {
  title:string = 'app';
  elementType:string = 'url';
  value = 'Techiediaries';
  constructor(
    private el: ElementRef,
    private http: HttpClient,
    private authTokenService: AuthTokenService,
  ) {
    this.createCode();
  }

  ngOnInit() {
  }

  createBarCode(){
  }

  ngAfterViewInit(): void {
    //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
    //Add 'implements AfterViewInit' to the class.
  
  }
  appUserId = this.authTokenService.getAppUserId();
  createCode() {
    let requestData = {
      appUserId:this.appUserId,//this.authTokenService.getAppUserId(),
    };
    let url = "/scm/app/getQrCode.do";
    this.http.post(url, requestData).subscribe((response: any) => {
      let body = response.responseBody;
      // if(!body.transactionToken){
      //   alert("qrCode error");
      //   return;
      // }
      this.value = response.responseBody;
      // if(body.codeOutTime != 0){
      //   let date = new Date(body.codeCreateTime);
      //   let minute = date.getMinutes();
      //   let outTime = minute + body.codeOutTime;
      //   date.setMinutes(outTime);
      //   let currentDate = new Date();
      //   if(currentDate.getTime() > date.getTime()){
      //     alert("time out");
      //   }
      // }
    });
  }
}
